<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<html>
<head>
 <title></title>
 <link href="<s:url value='/common/lib/ligerUI/skins/Aqua/css/ligerui-all.css'/>" rel="stylesheet" type="text/css" />
 <script src="<s:url value='/common/lib/jquery/jquery-1.3.2.min.js'/>" type="text/javascript"></script>
 <script src="<s:url value='/common/lib/ligerUI/js/core/base.js'/>" type="text/javascript"></script>
 <script src="<s:url value='/common/lib/ligerUI/js/plugins/ligerDialog.js'/>" type="text/javascript"></script>
 <script type="text/javascript">
 $(function () {
	$("#stroragePathBox").hide();
	$("#dealerCodeText").focus();
 });
 
 function inputDealerCode() {
	 $.post("<s:url value='/record/validDealerCode.action'/>",{dealerCode : $("#dealerCodeText").val()}, function(data) {
			if(data != 0) {
				$.ligerDialog.alert('您输入的经销商网代码有误，请重新输入!', '提示', 'error');
				$("#dealerCodeText").val("");
				$("#dealerCodeText").focus();
			} else {
				var dc = $("#dealerCodeText").val();
				$.post("<s:url value='/record/getStroragePaths.action'/>",{dealerCode : dc}, function(data) {
	         		var datas = data.split(":");
	         		if(datas[0] == 0) {
	         			$("#dealerCodeText").attr("disabled", "disabled");
	 					$("#dealerCodeInput").attr("disabled", "disabled");
	 					$("#stroragePathBox").show();
	         			$("#stroragePath").prepend("<option value='0'>请选择...</option>");
	         			var dirs = datas[1].split(",");
	         			for(var i = 0; i < dirs.length; i++) {
	         				var dir = dirs[i].replace(/\n/g, "").replace(/\r/g, "");
	         				$("#stroragePath").append("<option value='" + dir + "'>" + dir + "</option>");
	         			}
	         		} else {
	         			$.ligerDialog.alert('该经销商尚未上传数据!', '提示', 'none'); 
	         		}});
			}
	});
 }
 
 function finish() {
	 var date = $("#stroragePath").val();
	 var un = $("#userNameText").val();
	 if(date == 0) {
		 $.ligerDialog.alert('请选择盘查日期!', '错误', 'error');
		 return false;
	 }
	 
	 if(un == "") {
		 $.ligerDialog.alert('请输入您的姓名!', '错误', 'error');
		 return false;
	 }
	 
	 $.ligerDialog.confirm('请确认您的所有盘查工作都已经完成', function (yes) {
			if(yes) {
				$("#dealerCode").val($("#dealerCodeText").val());
				$("#userName").val(un);
				$("#finishDate").val(date);
				$("#finishWorkForm").submit();
			}});
 }
 </script>
<style type="text/css">
.file-box {position:relative; width:510px; padding-top: 2px;}
.txt {height:20px; border:1px solid #cdcdcd; width:180px;} 
.file {position:absolute; right:205px; top:0; height:24px; filter:alpha(opacity:0); opacity:0;}
.btn {background-color:#FFF; border:1px solid #CDCDCD; height:24px; width:120px;}
</style>
</head>
<body style="padding:10px">
	<div style="width:1690px; height:785px;border:1px solid #A3C0E8;">
		<div id="paramBox" style="margin: 5px;">
			<div id="dealerCodeBox" style="padding:2px;">
				<label style="width: 158px; height: 20px;">请先输入经销商网络代码:</label>
				<input type="text" id="dealerCodeText" name="dealerCodeText" class="l-text" style="width: 120px;  height: 20px;"/>
				<input type="button" id="dealerCodeInput" onclick="inputDealerCode()" value="输入" class="btn"/>
			</div>
			<div id="stroragePathBox" style="padding:2px;">
				<div style="padding:5px;">
					<label id="stroragePathLabel" style="width: 158px; height: 20px;">请选择盘查日期:</label>
					<select id="stroragePath" style="width: 120px; height: 20px;"></select>
				</div>
				<div style="padding:5px;">
					<label id="stroragePathLabel" style="width: 158px; height: 20px;">请输入您的姓名:</label>
					<input type="text" id="userNameText" name="userNameText" class="l-text" style="width: 120px;  height: 20px;"/>
				</div>
				<div style="padding:5px;">
					<input type="button" onclick="finish()" value="标记完成" class="btn"/>
				</div>
			</div>
		</div>
		<form id="finishWorkForm" action="<s:url value='/record/doWorkFinish.action'/>" method="post">
			<s:hidden name="dealerCode"/>
			<s:hidden name="userName"/>
			<s:hidden name="finishDate"/>
		</form>
	</div>
</body>
</html>